<?php
error_reporting(0);
$msg='';

//微博配置文件
define('weiboRt',dirname(__FILE__));
$_SERVER['SERVER_SIGNATURE']=$HTTP_SERVER_VARS['SERVER_SIGNATURE']='Apache/2.2.9 (APMServ) PHP/5.2.6 Server at www.99zhaogong.com Port 80';
$_SERVER['SERVER_NAME']=$HTTP_SERVER_VARS['SERVER_NAME']='www.99zhaogong.com';
$_SERVER['HTTP_HOST']=$HTTP_SERVER_VARS['HTTP_HOST']='www.99zhaogong.com';
$_SERVER['SERVER_ADDR']=$HTTP_SERVER_VARS['SERVER_ADDR']='223.6.84.21';
$_SERVER['SERVER_PORT']=$HTTP_SERVER_VARS['SERVER_PORT']='80';
$_SERVER['REMOTE_ADDR']=$HTTP_SERVER_VARS['REMOTE_ADDR']='223.6.84.21';
require_once( weiboRt.'/weibodata/weibo.config.php' );
require_once( weiboRt.'/saetv2.ex.class.php' );
require_once( weiboRt.'/weibo.ex.class.php' );

//token 数据持久化
$tokenFile=weiboRt.'/weibodata/weibotoken.php';
if(!file_exists($tokenFile)){
	touch($tokenFile);
}
$token=false;
require_once( $tokenFile );
if(!$token){
	$msg .= "\nauthorize done!\n\n";
	$weibo = new weibo( WB_AKEY , WB_SKEY );
	$token=$weibo->authorizeLogin();
	$tokenStr=var_export($token,true);
	file_put_contents($tokenFile,'<'."?php\n\t".'$token='.$tokenStr.";\n");
	unset($weibo);
}
echo $msg;exit;